package com.example.demo.utils;

import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;

public class PromptLoaderUtil {


    private final String prompt;

    /**
     * 构造时直接传 classpath 相对路径，例如 "/prompt_sub.txt"
     */
    public PromptLoaderUtil(String classpathFile) throws IOException {
        try (InputStream in = PromptLoaderUtil.class.getResourceAsStream(classpathFile)) {
            if (in == null) {
                throw new IllegalArgumentException("classpath 下找不到：" + classpathFile);
            }
            this.prompt = new String(in.readAllBytes(), StandardCharsets.UTF_8);
        }
    }

    public String getPrompt() {
        return prompt;
    }
}
